package string;

public class IsPalindrome {
    public static void main(String[] args) {
        String content = "A man, a plan, a canal: Panama";
        boolean ret = isPalindrome(content);
        System.out.println(ret);
    }

    public static boolean isPalindrome(String s) {
        s = s.toLowerCase();
        StringBuffer sb = new StringBuffer();
        int len = s.length();
        for (int i = 0; i < len; i++) {
            char charAt = s.charAt(i);
            if (Character.isLetterOrDigit(charAt)) {
                sb.append(charAt);
            }
        }

        System.out.println(sb.toString());
        StringBuffer reverse = new StringBuffer(sb).reverse();

        return sb.toString().equals(reverse.toString());
    }
}
